var ds_distributer_review = new Ext.data.Store({
			proxy : new Ext.data.HttpProxy({
						url : 'manuscript_list.action',
						method : 'POST'
					}),
			baseParams : {
				type : 4
			},
			reader : new Ext.data.JsonReader({
						root : 'manuscriptList',
						totalProperty : 'total'
					}, [{
								name : 'manuscriptId',
								mapping : 'manuscriptId',
								type : 'long'
							}, {
								name : 'contributeCompanyName',
								mapping : 'contributeCompany.contributeCompanyName',
								type : 'string'
							}, {
								name : 'manuscriptCategoryName',
								mapping : 'manuscriptCategory.manuscriptCategoryName',
								type : 'string'
							}, {
								name : 'title',
								mapping : 'title',
								type : 'string'
							}, {
								name : 'plannedConsummationTime',
								mapping : 'plannedConsummationTime',
								type : 'long'
							}, {
								name : 'urgence',
								mapping : 'urgence',
								type : 'short'
							}, {
								name : 'securityClassification',
								mapping : 'securityClassification',
								type : 'short'
							}, {
								name : 'operation',
								type : 'string'
							}, {
								name : 'manuscriptWorks',
								mapping : 'manuscriptWorks',
								type : 'string'
							}])
		});

var tip="6为最高级别";
function totime(value, metadata, record) {
	return new Date(value).format('Y-m-d H:i');
}
function bankTime(value, metadata, record) {
	return new Date(value).format('Y-m-d');
}
function tourgence(value) {
	switch (value) {
		case 0 :
			return "普通";
			break;
		case 5 :
			return "紧急";
			break;
		case 10 :
			return "特急";
			break;
	}
}

function distributerReviewAgain(prama){
	if (prama == "") {
		return "分发审核";
	} else {
		return "重新分发";
	}
}

function tosecurityClassification(value) {
	switch (value) {
		case 1 :
			return "普通";
			break;
		case 2 :
			return "秘密";
			break;
		case 3 :
			return "机密";
			break;
		case 5 :
			return "绝密";
			break;
	}
}

function toSecurityGrade(value) {
	switch (value) {
		case 1 :
			return "普通";
			break;
		case 2 :
			return "秘密";
			break;
		case 3 :
			return "机密";
			break;
		case 5 :
			return "绝密";
			break;
	}
}

function tolanguage(value) {
	switch (value) {
		case 1 :
			return "汉语";
			break;
		case 2 :
			return "藏语";
			break;
	}
}

function totargetLanguage(value) {
	switch (value) {
		case 1 :
			return "汉语";
			break;
		case 2 :
			return "藏语";
			break;
	}
}

function totexttype(value) {
	switch (value) {
		case 0 :
			return "纸质稿件";
			break;
		case 0x0100 :
			return "电子稿件";
			break;
	}
}

function totype(value) {
	if(value=="DW"){
		return "党委";
	}else if(value=="RD"){
		return "人大";
	}else if(value=="ZF"){
		return "政府";
	}else if(value=="ZX"){
		return "政协";
	}else if(value=="QT"){
		return "其他";
	}else{
		return value;
	}
}

var urgence;
var securityClassification;
var language;
var targetLanguage;
var contributeTime;
var plannedConsummationTime;
var type;
var texttype;
function formchange(respText) {
	urgence = tourgence(respText.manuscript.urgence);
	securityClassification = tosecurityClassification(respText.manuscript.securityClassification);
	language = tolanguage(respText.manuscript.language);
	targetLanguage = totargetLanguage(respText.manuscript.targetLanguage);
	contributeTime = totime(respText.manuscript.contributeTime, "", "");
	plannedConsummationTime = totime(
			respText.manuscript.plannedConsummationTime, "", "");
	texttype = totexttype(respText.manuscript.type);
	type = totype(respText.contributeCompany.type);
}


var re;
function tomark(value, metadata, record) {
    var title = '&nbsp;密级&nbsp;&nbsp;&nbsp;&nbsp;紧急程度&nbsp;';
    var tip;
    var s1 = "&nbsp;普通&nbsp;&nbsp;&nbsp;&nbsp;";
    var s2 = "&nbsp;秘密&nbsp;&nbsp;&nbsp;&nbsp;";
    var s3 = "&nbsp;机密&nbsp;&nbsp;&nbsp;&nbsp;";
    var s5 = "&nbsp;绝密&nbsp;&nbsp;&nbsp;&nbsp;";
    var u0 = "&nbsp;&nbsp;&nbsp;普通&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    var u5 = "&nbsp;&nbsp;&nbsp;紧急&nbsp;&nbsp;&nbsp;&nbsp;";
    var u10 = "&nbsp;&nbsp;&nbsp;特急";
    var c0 = "&nbsp<img src='images/clock_blue.gif'  />&nbsp";// 普通urgence
    var c5 = "&nbsp<img src='images/clock_green.gif' />&nbsp";// 紧急
    var c10 = "&nbsp<img src='images/clock_red.gif' />&nbsp";// 特急
    var l1 = "&nbsp<img src='images/lock_blue.gif'  />&nbsp";// 普通securityClassification
    var l2 = "&nbsp<img src='images/lock_gold.gif'/>&nbsp"; // 秘密
    var l3 = "&nbsp<img src='images/lock_green.gif' />&nbsp";// 机密
    var l5 = "&nbsp<img src='images/lock_red.gif'  />&nbsp";// 绝密
    switch (record.data.securityClassification) {
        case 1:
            switch (record.data.urgence) {
                case 0:
                	re = l1 + c0;
                    tip = s1 + u0;
                    break;
                case 5:
                	re = l1 + c5 ;
                    tip = s1 + u5;
                    break;
                case 10:
                	re = l1 + c10;
                    tip = s1 + u10;
                    break;
            }
            break;
        case 2:
            switch (record.data.urgence) {
                case 0:
                	re = l2 + c0;
                    tip = s2 + u0;
                    break;
                case 5:
                	re = l2 + c5;
                    tip = s2 + u5;
                    break;
                case 10:
                	re = l2 + c10;
                    tip = s2 + u10;
                    break;
            }
            break;
        case 3:
            switch (record.data.urgence) {
	            case 0:
	            	re = l3 + c0;
	                tip = s3 + u0;
	                break;
	            case 5:
	            	re = l3 + c5;
	                tip = s3 + u5;
	                break;
	            case 10:
	            	re = l3 + c10;
	                tip = s3 + u10;
	                break;
            }
            
            break;
        case 5:
            switch (record.data.urgence) {
	            case 0:
	            	re = l5 + c0;
	                tip = s5 + u0;
	                break;
	            case 5:
	            	re = l5 + c5;
	                tip = s5 + u5;
	                break;
	            case 10:
	            	re = l5 + c10;
	                tip = s5 + u10;
	                break;
	            }
            break;
    }
    metadata.attr = 'ext:qtitle="' + title + '"' + ' ext:qtip="' + tip + '"';
    return re;
}
function changeRemark(respText){
    return "<div align=\"center\"><a href='javascript:void(0)'  onclick=javascript:showRemark('" + respText.manuscript.manuscriptId + "')>备注详情</a></div>";
}

function changeWorkRemark(respText,i){
    return "<div align=\"center\"><a href='javascript:void(0)'  onclick=javascript:showWorkRemark('" + respText.manuscript.manuscriptId + "','"+i+"')>备注详情</a></div>";
}

window.showWorkRemark = function(v,i){
    Ext.Ajax.request({
        url: 'distributer_view.action',
        method: 'post',
        params: {
            manuscriptId: v
        },
        success: function(resp, opts){
            var respText = Ext.util.JSON.decode(resp.responseText);
            if (respText.success) {
                var window_remark = new Ext.Window({
                    title: '备注详情',
                    closable: false,
                    width: 600,
                    resizable: false,
                    height: 400,
                    iconCls: 'manuscript',
                    modal: true,
                    constrain: true,
                    closeAction: 'close',
                    layout: 'fit',
                    items: [{
                        xtype: 'htmleditor',
                        enableAlignments: false,
                        enableColors: false,
                        enableFont: false,
                        enableFontSize: false,
                        enableFormat: false,
                        enableLinks: false,
                        enableLists: false,
                        enableSourceEdit: false,
                        readOnly: true,
                        value: respText.manuscriptWorksByManuscript[i].remark
                    }],
                    buttons: [{
                        text: '关闭',
                        handler: function(){
                            window_remark.close();
                        }
                    }]
                
                
                }).show();
            }
        },
        failure: function(){
            Ext.Msg.show({
                title: '错误提示',
                msg: '查看失败!',
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.ERROR,
                width: 200
            });
        }
    })
};

window.showRemark = function(v){
    Ext.Ajax.request({
        url: 'manuscript_view.action',
        method: 'post',
        params: {
            manuscriptId: v
        },
        success: function(resp, opts){
            var respText = Ext.util.JSON.decode(resp.responseText);
            if (respText.success) {
                var window_remark = new Ext.Window({
                    title: '备注详情',
                    closable: false,
                    width: 600,
                    resizable: false,
                    height: 400,
                    iconCls: 'manuscript',
                    modal: true,
                    constrain: true,
                    closeAction: 'close',
                    layout: 'fit',
                    items: [{
                        xtype: 'htmleditor',
                        enableAlignments: false,
                        enableColors: false,
                        enableFont: false,
                        enableFontSize: false,
                        enableFormat: false,
                        enableLinks: false,
                        enableLists: false,
                        enableSourceEdit: false,
                        readOnly: true,
                        value: respText.manuscript.remark
                    }],
                    buttons: [{
                        text: '关闭',
                        handler: function(){
                            window_remark.close();
                        }
                    }]
                
                
                }).show();
            }
        },
        failure: function(){
            Ext.Msg.show({
                title: '错误提示',
                msg: '查看失败!',
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.ERROR,
                width: 200
            });
        }
    })
};

window.showManuscriptTranslate = function(needParam) {
	Ext.Ajax.request({
		url : 'manuscriptDistributer_view.action',
		method : 'post',
		params : {
			manuscriptId : needParam
		},
		success : function(resp, opts) {
			var respText = Ext.util.JSON.decode(resp.responseText);
			if (respText.success) {
				formchange(respText);
				var mywindow = new Ext.Window({
					title : '稿件详情',
					width : 600,
					constrain: true,
					resizable : false,
					autoHeight : true,
					closable : false,
					modal : true,
					iconCls:'manuscript',
					closeAction : 'hide',
					items : [new Ext.FormPanel({
						border : false,
						labelAlign : 'right',
						plain : true,
						labelWidth : 100,
						frame : true,
						items : [{
								fieldLabel : '稿件标题',
								xtype : 'textfield',
								readOnly : true,
								value : respText.manuscript.title,
								width : 426,
								itemCls : "unedit"
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '来稿单位',
								readOnly : true,
								value : respText.contributeCompany.contributeCompanyName,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '来稿单位类型',
								readOnly : true,
								value : type,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '联系人',
								readOnly : true,
								value : respText.contributeCompanyPerson.name,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '稿件编号',
								readOnly : true,
								value : respText.manuscript.manuscriptCode,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '联系人手机',
								readOnly : true,
								value : respText.contributeCompanyPerson.mobilePhone,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '联系人邮箱',
								readOnly : true,
								value : respText.contributeCompanyPerson.email,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '稿件分类',
								readOnly : true,
								value : respText.manuscriptCategory.manuscriptCategoryName,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '紧急程度',
								readOnly : true,
								value : urgence,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '文档类型',
								readOnly : true,
								value : texttype,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '原稿文种',
								readOnly : true,
								value : language,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '密级',
								readOnly : true,
								value : securityClassification,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '目标语言',
								readOnly : true,
								value : targetLanguage,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '字数',
								readOnly : true,
								value : respText.manuscript.wordNum,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '来稿时间',
								readOnly : true,
								value : contributeTime,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '计划完成时间',
								readOnly : true,
								value : plannedConsummationTime,
								itemCls : 'form_text unedit'
							},{
								autoHeight : true,
								xtype : 'textfield',
								itemCls : 'form_text unedit',
								fieldLabel : '创建人姓名',
								value : respText.manuscript.creatorName,
								readOnly : true
							}, {
								autoHeight : true,
								xtype : 'textfield',
								itemCls : 'form_text unedit',
								fieldLabel : '创建时间',
								value : formatTime(respText.manuscript.createdTimestamp,"",""),
								readOnly : true
							},{
								autoHeight : true,
								xtype : 'textfield',
								itemCls : 'form_text unedit',
								fieldLabel : '最后修改人',
								value : respText.manuscript.lastModifierName,
								readOnly : true
							}, {
								autoHeight : true,
								xtype : 'textfield',
								itemCls : 'form_text unedit',
								fieldLabel : '最后修改时间',
								value : formatTime(respText.manuscript.lastModifiedTimestamp,"",""),
								readOnly : true
							}, {
	                            fieldLabel: '备注',
	                            xtype: 'panel',
	                            width: 425,
	                            itemCls: 'clear',
	                            html: changeRemark(respText)
	                        }],
							buttons : [{
					     		text : '关闭',
					     		handler : function() {
									mywindow.hide();
								}
					     	}]
					})]
				}).show();
			} else {
				Ext.Msg.show({
							title : '错误提示',
							msg : respText.erroeMessage,
							buttons : Ext.Msg.OK,
							icon : Ext.Msg.ERROR,
							width : 200
						});
			}
		},
		failure : function() {
			Ext.Msg.show({
						title : '错误提示',
						msg : '加载失败!',
						buttons : Ext.Msg.OK,
						icon : Ext.Msg.ERROR,
						width : 200
					});
		}
	});
}

addColor = function(param) {
	if (param == 256) {
		return 'green';
	} else if (param == 512) {
		return 'blue';
	} else if (param == 768) {
		return 'red';
	} else {
		return 'gray';
	}
}

isDisables = function(param) {
	if ((param & 0x1000) == 0x1000) {
		return "disabled='disabled'";
	} else {
		return "enabled='enabled'";
	}
}

choose = function(id){
	if(document.getElementById(id).disabled){
		document.getElementById(id).disabled = false;
	}else{
		document.getElementById(id).disabled = true;
	}
}

remove = function(id){
	if(Ext.get(id)!=null){
		Ext.get(id).remove();
	}
}

var toptip = "";
workShowReview = function(metadata,userId){
	Ext.Ajax.request({
		url : 'worksByPerson_list.action',
		method : 'post',
		async : false, 
		params : {
			userId : userId
		},
		success : function(resp, opts) {
			toptip = "";
			var respText = Ext.util.JSON.decode(resp.responseText);
			if(respText.success){
				manuscriptWorksByPerson = respText.manuscriptWorksByPerson;
				if(manuscriptWorksByPerson.length != 0){
					for (var i = 0; i < manuscriptWorksByPerson.length; i++) {
						if(manuscriptWorksByPerson[i].manuscript.title.length >10){
							toptip = toptip + escapeHTML(manuscriptWorksByPerson[i].manuscript.title.substring(0,10)) + "..." + "</br>";
						}else{
							toptip = toptip + escapeHTML(manuscriptWorksByPerson[i].manuscript.title) + "</br>";
						}
					}
				}
			}
		}
	});
	metadata.attr = ' ext:qtip="' + toptip + '"';
}

var cm_distributer_review = new Ext.grid.ColumnModel([
		new Ext.grid.RowNumberer(), {
			header : '稿件标题',
			dataIndex : 'title',
			width:300,
			sortable : true,
			renderer : function(value, metadata, record) {
				return "<a href = 'javascript:void(0)' onclick=javascript:showManuscriptTranslate('"
						+ record.data.manuscriptId + "')>" + escapeHTML(value) + "</a>";
			}
		}, {
			header : '来稿单位',
			width:150,
			dataIndex : 'contributeCompanyName',
			sortable : true
		}, {
			header : '稿件分类',
			dataIndex : 'manuscriptCategoryName',
			sortable : true
		}, {
			header : '计划完成时间',
			dataIndex : 'plannedConsummationTime',
			sortable : true,
			renderer : function change(value, metadata, record) {
//				return bankTime(value, metadata, record);
			    return new Date(value).format('Y-m-d');
			}
		}, {
			header : '标识',
			sortable : true,
			renderer : function drawmark(value, metadata, record) {
				return tomark(value, metadata, record);
			}
		}, {
			header : "操作",
			width : 120,
			dataIndex : 'operation',
			renderer : function(value, metadata, record) {
				return "<a href = 'javascript:void(0)' onclick=javascript:showDistributerReview('"
						+ record.data.manuscriptId + "')>"+distributerReviewAgain(record.data.manuscriptWorks)+"</a>";
			}
		}]);


var grid_distributer_reivse = new Ext.grid.GridPanel({
			title : '审核分发 ',
			loadMask : {
				msg : '数据加载中...'
			},
			ds : ds_distributer_review,
			store : ds_distributer_review,
			region : 'center',
			autoScroll : true,
			cm : cm_distributer_review,
			autoExpandColumn : 6,
			bbar : new Ext.PagingToolbar({
						pageSize : 20,
						store : ds_distributer_review,
						displayInfo : true,
						beforePageText : '第',
						afterPageText : '页-共{0}页',
						displayMsg : '显示{0} - {1} 条  共 {2} 条',
						emptyMsg : "没有记录"
					})
		});

ds_distributer_review.load({
			params : {
				start : 0,
				limit : 20
			}
		});
		
var review_tabPanel = new Ext.TabPanel({
		id : 'centerTabPanel',
		region : 'center',
		deferredRender : true,
		enableTabScroll : true,
		activeTab : 0, // first tab initially active
		defaults : {
			autoScroll : true,
			closable : false
		},
		items : [grid_distributer_reivse]
	});

function isRejected(prama1,prama2){
	var temp = "";
	if (prama2.length == 0) {
		return "";
	}
	for ( var i = 0; i < prama2.length; i++) {
		if (prama1 == prama2[i]) {
			temp = "<img src='images/bullet_error.png' title='曾经拒绝过该任务' alt='曾经拒绝过该任务'>";
			break;
		}
	}
	return temp;
}

window.showDistributerReview = function(needParam) {
	if(Ext.get('win_add_work')!= null){
		review_tabPanel.remove(Ext.getCmp('win_add_work'));
		review_tabPanel.setActiveTab(0);
	}
	
	Ext.Ajax.request({
		url : 'distributer_view.action',
		method : 'post',
		params : {
			manuscriptId : needParam,workType:4
		},
		success : function(resp, opts) {
			var respText = Ext.util.JSON.decode(resp.responseText);
			if (respText.success) {
				var ds_translate = new Ext.data.Store({
					proxy : new Ext.data.MemoryProxy(respText),
					baseParams : {manuscriptId : needParam,workType:1},
					reader : new Ext.data.JsonReader({
								root : 'usersForDistribute'
							}, [{name : 'userId',mapping : 'userId',type : 'long'},
								{name : 'userName',mapping : 'userName',type : 'string'},
								{name : 'status',mapping : 'status',type : 'long'},
								{name : 'ability',mapping : 'ability',type : 'long'},
								{name : 'status',mapping : 'status',type : 'long'},
								{name : 'securityGrade',mapping : 'securityGrade',type : 'long'},
								{name : 'mobilePhone',mapping : 'mobilePhone',type : 'string'},
								{name : 'email',mapping : 'email',type : 'string'}]
						)
				});
				var sm_user=new Ext.grid.CheckboxSelectionModel();
				var cm_translate = new Ext.grid.ColumnModel([
					new Ext.grid.RowNumberer(),
					{header:'稿件工作人员',dataIndex:'userName',width:150,renderer:function(value, metadata, record)
						{
							workShowReview(metadata,record.data.userId);
				    	 	return "<input type='checkbox' name='manuscriptWorkersId' value='"+record.data.userId+"' onclick=choose('radio"+record.data.userId+"') "+isDisables(record.data.status)+">  <font color='"+addColor(record.data.status)+"'>"+escapeHTML(record.data.userName)+isRejected(record.data.userId,respText.rejectedPersonId)+"</font></input>";
						}
					},
					{header:'是否为统稿人',dataIndex:'userId',width:120,renderer:function(value, metadata, record)
						{
							remove('radio'+record.data.userId);
				    	 	return "<input type='radio' name='manuscriptWork.principalId' value='"+record.data.userId+"' disabled='true' id='radio"+record.data.userId+"'/>";
						}
					},
					{header:'能力级别',dataIndex:'ability',
						renderer: function(value,metadata,record){
							metadata.attr =' ext:qtip="' + tip + '"';
							return "<font color='#2B76C8'>"+value+"</font>";
					    },
						width:120,sortable:true},
					{header:'涉密级别',dataIndex:'securityGrade',width:120,sortable:true,renderer: function change(value, metadata, record){
					        return tosecurityClassification(value, metadata, record);
					    }
					},
					{header:'手机',dataIndex:'mobilePhone',width:150,sortable:true},
					{header:'电子邮箱',dataIndex:'email',sortable:true}
				]);
				var grid_translate = new Ext.grid.GridPanel({
					loadMask : {
						msg : '数据加载中...'
					},
					ds : ds_translate,
					store : ds_translate,
					region : 'form_distributer',
					autoScroll : true,
					cm : cm_translate,
					autoExpandColumn :6,
					maxHeight : 250,
					autoHeight : true
				});
				ds_translate.load();
				formchange(respText);
				var form_distributer = new Ext.form.FormPanel({
					title : '选择审核人员',
					id : 'form_distributer',
					autoHeight : true,
					labelAlign : 'right',
					frame : true,
					items : [grid_translate,{
								xtype : 'datefield',
								name : 'plannedFinishedTime',
								itemCls:'form_text',
								editable : false,
								emptyText : '请选择',
								allowBlank : false,
								minValue : new Date().format('Y-m-d'),
								fieldLabel : '要求完成时间',
								format : 'Y-m-d'
							},{
								fieldLabel : '工作任务描述',
								xtype : 'textarea',
								anchor : '98%',
								maxLength : 200,
								name : 'manuscriptWork.description',
								itemCls : 'clear'
							}],
					buttons : [{
						text : '分发',
						type : 'submit',
						handler : function() {
						if(form_distributer.form.isValid()){
							Ext.Msg.confirm('分发确认', '你确定要分发稿件?', function(btn) {
								if(btn=='yes'){
									form_distributer.form.doAction('submit', {
										url : 'distributerManuscript_add.action',
										method : 'post',
										params : {
										type : 4,
										manuscriptId : needParam
									},
									success : function(form, action) {
										if (action.result.success) {
											Ext.Msg.show({
												title : '操作提示',
												msg : '分发成功!',
												buttons : Ext.Msg.OK,
												icon : Ext.Msg.INFO,
												width : 200
											});
											review_tabPanel.remove(Ext.getCmp('win_add_work'));
											review_tabPanel.setActiveTab(0);
											ds_distributer_review.reload();
										} else {
											Ext.Msg.show({
												title : '错误提示',
												msg : action.result.errorMessage,
												buttons : Ext.Msg.OK,
												icon : Ext.Msg.ERROR,
												width : 200
											});
										}
									},
									failure : function(from, action) {
										if(action.result == null){
											Ext.Msg.show({
												title : '错误提示',
												msg : '数据不符合要求',
												buttons : Ext.Msg.OK,
												icon : Ext.Msg.ERROR,
												width : 200
											});
										}else{
											if(!action.result.success){
												Ext.Msg.show({
													title : '错误提示',
													msg : action.result.errorMessage,
													buttons : Ext.Msg.OK,
													icon : Ext.Msg.ERROR,
													width : 200
												});
											}
										}
									}
									});
								}
							})
						}	
						}
					}, {
						text : '重置',
						handler : function() {
							form_distributer.form.reset();
						}
					},{
					     		text : '关闭',
					     		handler : function() {
									review_tabPanel.remove(Ext.getCmp('win_add_work'));
									review_tabPanel.setActiveTab(0);
								}
					     	}]
				});
				var form_manuscript = new Ext.Panel({
					title : '稿件详情',
					border : false,
					labelAlign : 'right',
					plain : true,
					labelWidth : 100,
					frame : true,
					layout : 'form',
					items : [{
								fieldLabel : '稿件标题',
								xtype : 'textfield',
								readOnly : true,
								value : respText.manuscript.title,
								width : 426,
								itemCls : "unedit"
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '来稿单位',
								readOnly : true,
								value : respText.contributeCompany.contributeCompanyName,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '来稿单位类型',
								readOnly : true,
								value : type,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '联系人',
								readOnly : true,
								value : respText.contributeCompanyPerson.name,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '稿件编号',
								readOnly : true,
								value : respText.manuscript.manuscriptCode,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '联系人手机',
								readOnly : true,
								value : respText.contributeCompanyPerson.mobilePhone,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '联系人邮箱',
								readOnly : true,
								value : respText.contributeCompanyPerson.email,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '稿件分类',
								readOnly : true,
								value : respText.manuscriptCategory.manuscriptCategoryName,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '紧急程度',
								readOnly : true,
								value : urgence,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '文档类型',
								readOnly : true,
								value : texttype,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '原稿文种',
								readOnly : true,
								value : language,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '密级',
								readOnly : true,
								value : securityClassification,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '目标语言',
								readOnly : true,
								value : targetLanguage,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '字数',
								readOnly : true,
								value : respText.manuscript.wordNum,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '来稿时间',
								readOnly : true,
								value : contributeTime,
								itemCls : 'form_text unedit'
							}, {
								autoHeight : true,
								xtype : 'textfield',
								fieldLabel : '计划完成时间',
								readOnly : true,
								value : plannedConsummationTime,
								itemCls : 'form_text unedit'
							}, {
	                            fieldLabel: '备注',
	                            xtype: 'panel',
	                            width: 425,
	                            itemCls: 'clear',
	                            html: changeRemark(respText)
	                        }]
				});
				var manuscriptWorksByManuscript = respText.manuscriptWorksByManuscript;
				var form_translate = '';
				var form_check = '';
				var form_revise = '';
				for ( var i = 0; i < manuscriptWorksByManuscript.length; i++) {
					if (manuscriptWorksByManuscript[i].type == 1 && manuscriptWorksByManuscript[i].status == 3) {
						form_translate = new Ext.Panel({
							title : '翻译详情',
							border : false,
							labelAlign : 'right',
							plain:true,
							labelWidth : 100,
							frame : true,
							layout : 'form',
							items : [{
										fieldLabel : '翻译人',
										xtype : 'textfield',
										readOnly : true,
										value : manuscriptWorksByManuscript[i].principalName,
										itemCls:'form_text unedit'
									}, {
										autoHeight : true,
										xtype : 'textfield',
										fieldLabel : '翻译完成时间',
										readOnly : true,
										value : totime(manuscriptWorksByManuscript[i].actualFinishedTime, "", ""),
										itemCls:'form_text unedit'
									}, {
										autoHeight : true,
										xtype : 'textfield',
										fieldLabel : '总字数',
										readOnly : true,
										value : manuscriptWorksByManuscript[i].wordNum,
										itemCls:'form_text unedit'
									},{
			                            fieldLabel: '备注',
			                            xtype: 'panel',
			                            width: 425,
			                            itemCls: 'clear',
			                            html: changeWorkRemark(respText,i)
			                        }]
							});
					}else if (manuscriptWorksByManuscript[i].type == 2 && manuscriptWorksByManuscript[i].status == 3) {
						form_check = new Ext.Panel({
							title : '校审详情',
							border : false,
							labelAlign : 'right',
							plain:true,
							labelWidth : 100,
							frame : true,
							layout : 'form',
							items : [{
										fieldLabel : '校审人',
										xtype : 'textfield',
										readOnly : true,
										value : manuscriptWorksByManuscript[i].principalName,
										itemCls:'form_text unedit'
									}, {
										autoHeight : true,
										xtype : 'textfield',
										fieldLabel : '校审完成时间',
										readOnly : true,
										value : totime(manuscriptWorksByManuscript[i].actualFinishedTime, "", ""),
										itemCls:'form_text unedit'
									}, {
										autoHeight : true,
										xtype : 'textfield',
										fieldLabel : '总字数',
										readOnly : true,
										value : manuscriptWorksByManuscript[i].wordNum,
										itemCls:'form_text unedit'
									},{
			                            fieldLabel: '备注',
			                            xtype: 'panel',
			                            width: 425,
			                            itemCls: 'clear',
			                            html: changeWorkRemark(respText,i)
			                        }]
							});
					}else if (manuscriptWorksByManuscript[i].type == 3 && manuscriptWorksByManuscript[i].status == 3) {
						form_revise = new Ext.Panel({
							title : '校对详情',
							border : false,
							labelAlign : 'right',
							plain:true,
							labelWidth : 100,
							frame : true,
							layout : 'form',
							items : [{
										fieldLabel : '校对人',
										xtype : 'textfield',
										readOnly : true,
										value : manuscriptWorksByManuscript[i].principalName,
										itemCls:'form_text unedit'
									}, {
										autoHeight : true,
										xtype : 'textfield',
										fieldLabel : '校对完成时间',
										readOnly : true,
										value : totime(manuscriptWorksByManuscript[i].actualFinishedTime, "", ""),
										itemCls:'form_text unedit'
									}, {
										autoHeight : true,
										xtype : 'textfield',
										fieldLabel : '总字数',
										readOnly : true,
										value : manuscriptWorksByManuscript[i].wordNum,
										itemCls:'form_text unedit'
									},{
			                            fieldLabel: '备注',
			                            xtype: 'panel',
			                            width: 425,
			                            itemCls: 'clear',
			                            html: changeWorkRemark(respText,i)
			                        }]
							});
					}
				}
				var win_add_work ={
							title : '选择审核人员',
							autoWidth : true,
							height:600,
							closable : true,
							id : 'win_add_work',
							autoScroll : true,
							modal : true,
							items : [form_distributer, form_manuscript,form_translate,form_check,form_revise]
						};
				review_tabPanel.add(win_add_work);
				review_tabPanel.setActiveTab(1);
			} else {
				Ext.Msg.show({
							title : '错误提示',
							msg : respText.erroeMessage,
							buttons : Ext.Msg.OK,
							icon : Ext.Msg.ERROR,
							width : 200
						});
			}
		},
		failure : function() {
			Ext.Msg.show({
						title : '错误提示',
						msg : '加载失败!',
						buttons : Ext.Msg.OK,
						icon : Ext.Msg.ERROR,
						width : 200
					});
		}
	});
}

var l_distributer_review = {
	id : 'distributer-review',
	border : false,
	layout : 'border',
	items : [review_tabPanel]
};

Ext.getCmp('content-panel').add(l_distributer_review);
Ext.getCmp('content-panel').layout.setActiveItem('distributer-review');